$(function() {
	init();
	optionSearch();

});
var str = location.search;
str = str.slice(1).split('&');
var json = {};
for(var i = 0; i < str.length; i++) {
	var a = str[i].split('=');
	json[a[0]] = a[1];
}
console.log(json);

function init() {
      // 工人工资管理
    //console.log($(".inpDate").val());

    $("#table-fundManage").bootstrapTable({
        method: "post",
        url: "http://192.168.59.3:8082/console/selectWorkerMoneyMgtList",
        contentType: "application/json",
        queryParams: function (params) {
            params.pageNum = 1;
            params.pageSize = 10;
            params.projectCode = json.projectCode;
            params.teamId = json.teamId;
            params.UserCode = $(".order-num>input").eq(0).val();
            params.userName = $(".order-num>input").eq(1).val();
            params.idcardNum= $(".order-num>input").eq(2).val();
            params.month = $(".inpDate").val();
            console.log(params);
            return params;
        },
        onClickRow: function (row, value) {
            var str = "";
            for (var key in row) {
                str += "&" + key + "=" + row[key];
            }
            layer.open({
                type: 2,
                maxmin: true,
                shadeClose: true,
                area: ['100%', '100%'],
                content: `../siteData/worker-att-detail/worker-att-detail.html?${str.slice(1)}`
            });
        },
        onSuccessLoad:function (data) {
            console.log(data);
        },
        responseHandler: function (res) {
            console.log(res);
            return {rows: res.data, total: res.data.total};
        }
    });


	// 材料资金管理
    $("#pjTable1").bootstrapTable({
        method: "post",
        url: "http://192.168.59.3:8082/console/projectcapital/getShopCapitalListByType",
        contentType: "application/json",
        queryParams: function (params) {
            params.pageNum = 1;
            params.pageSize = 10;
            params.projectCode = json.projectCode;
            params.teamId = 1001;
            params.type = 1;
            params.teamUserCode = $(".order-num1>input").eq(0).val();
            params.supplierUserName = $(".order-num1>input").eq(1).val();
            params.month = $(".inpDate").val();
            console.log(params);
            return params;
        },
        onClickRow: function (row, value) {
            var str = "";
            for (var key in row) {
                str += "&" + key + "=" + row[key];
            }
            layer.open({
                type: 2,
                maxmin: true,
                shadeClose: true,
                area: ['100%', '100%'],
                content: `fund4.html?${str.slice(1)}`
            });
        },
        responseHandler: function (res) {
            console.log(res);
            return {rows: res.data, total: res.data.total};
        },
        onLoadSuccess: function (data) {
            console.log(data);
        }
    });
    // 设备管理
    $("#table-fundManage3").bootstrapTable({
        method: "post",
        url: "http://192.168.59.3:8082/console/projectcapital/getShopCapitalListByType",
        contentType: "application/json",
        queryParams: function (params) {
            params.pageNum = 1;
            params.pageSize = 10;
            params.projectCode = json.projectCode;
            params.type = 2;
            params.teamUserCode = $(".order-num2>input").eq(0).val();
            params.supplierUserName = $(".order-num2>input").eq(1).val();
            params.month = $(".inpDate").val();
            console.log(params);
            return params;
        },
        onClickRow: function (row, value) {
            var str = "";
            for (var key in row) {
                str += "&" + key + "=" + row[key];
            }
            layer.open({
                type: 2,
                maxmin: true,
                shadeClose: true,
                area: ['100%', '100%'],
                content: `device2.html?${str.slice(1)}`
               });
             },
        responseHandler: function (res) {
            console.log(res);
            return {rows: res.data.list, total: res.data.total};
            },
        onLoadSuccess: function (data) {
            console.log(data);
            }
      });

// 设施管理
    $("#table-fundManage2").bootstrapTable({
        method: "post",
        url: "http://192.168.59.3:8082/console/projectcapital/getShopCapitalListByType",
        contentType: "application/json",
        queryParams: function (params) {
            params.pageNum = 1;
            params.pageSize = 10;
            params.projectCode = json.projectCode;
            params.teamId = 1002;
            params.type = 3;
            params.teamUserCode = $(".order-num3>input").eq(0).val();
            params.supplierUserName = $(".order-num3>input").eq(1).val();
            params.month = $(".inpDate").val();
            console.log(params);
            return params;
        },
        onClickRow: function (row, value) {
            var str = "";
            for (var key in row) {
                str += "&" + key + "=" + row[key];
            }
            layer.open({
                type: 2,
                maxmin: true,
                shadeClose: true,
                area: ['100%', '100%'],
                content: `platformReport.html?${str.slice(1)}`
            });
        },
        responseHandler: function (res) {
            console.log(res);
            return {rows: res.data.list, total: res.data.total};
        },
        onLoadSuccess: function (data) {
            console.log(data);
        }
    });

};
  // 搜索查询公司



function indexFmt(val, row, index) {
	return index + 1;
}

function resHandler(response) {
	console.log(response);
	var needData = {
		rows: response.data.list,
		total: response.total
	};
	return needData;
}
function resHandler1(response) {
    console.log(response);
    var needData = {
        rows: response.list,
        total: response.data
    };
    return needData;
}


function processFmt(val, row, index) {
	return "<a href='#' class='vDetails' >" + val + " 查看详情</a>";
}

function optionSearch() {
	$("#clearoption").click(function() {

		for(var i = 0; i < 3; i++) {
			$(".order-num>input").eq(i).val("");

		}

		$("#table-fundManage").bootstrapTable('refresh');

	});
    $("#clearoption1").click(function() {

        for(var i = 0; i < 3; i++) {
            $(".order-num1>input").eq(i).val("");

        }

        $("#pjTable1").bootstrapTable('refresh');

    });
    $("#searchOption1").on("click", function() {
        $("#pjTable1").bootstrapTable("refresh");
    });

    $("#clearoption2").click(function() {

        for(var i = 0; i < 3; i++) {
            $(".order-num2>input").eq(i).val("");

        }

        $("#table-fundManage3").bootstrapTable('refresh');

    });
    $("#searchOption2").on("click", function() {
        $("#table-fundManage3").bootstrapTable('refresh');
    });


    $("#clearoption3").click(function() {

        for(var i = 0; i < 3; i++) {
            $(".order-num3>input").eq(i).val("");
        }
        $("#table-fundManage2").bootstrapTable('refresh');

    });
    $("#searchOption3").on("click", function() {
        $("#table-fundManage2").bootstrapTable('refresh');

    });


	$("#searchOption").on("click", function() {
		$("#table-fundManage").bootstrapTable("refresh");
    });



// function optNum() {
// 	var heNanCity = ['信阳市', '郑州市', '开封市', '洛阳市', '周口市'];
// 	var shanXiCity = ['沈阳市', '大连市', '锦州市', '鞍山市']
//
// 	var sel1 = document.getElementById("sel1");
//
// 	var sel2 = document.getElementById("sel2");
//
// 	sel1.onchange = function() {
//
// 		for(var i = 0; i < sel2.children.length; i++) {
// 			debugger;
//
// 			sel2.removeChild(sel2.children[i]);
// 			i--;
// 		}
//
// 		if(sel1.value == 1) {
// 			for(var j = 0; j < heNanCity.length; j++) {
//
// 				var optionObj = document.createElement('option');
//
// 				optionObj.innerHTML = heNanCity[j];
//
// 				sel2.appendChild(optionObj);
// 			}
// 		}
//
// 		if(sel1.value == 2) {
// 			for(var k = 0; k < shanXiCity.length; k++) {
//
// 				var optionObj = document.createElement('option');
//
// 				optionObj.innerHTML = shanXiCity[k];
//
// 				sel2.appendChild(optionObj);
// 			}
// 		}
// 	}

}